package com.rattsoftware.client.controllers;

import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.rattsoftware.client.events.AppEvents;
import com.rattsoftware.client.views.HomePageView;

public class HomePageController extends Controller {

	private HomePageView homeView;

	public HomePageController() {
		registerEventTypes(AppEvents.Init);
		registerEventTypes(AppEvents.HomeView);
		registerEventTypes(AppEvents.NavHomePage);
	}

	@Override
	public void handleEvent(AppEvent event) {
		EventType type = (EventType) event.getType();
		if (type == AppEvents.Init) {
			forwardToView(homeView, event);
		} else if (type == AppEvents.HomeView) {
			forwardToView(homeView, event);
		}  else if (type == AppEvents.NavHomePage) {
			forwardToView(homeView, event);
		}		
	}

	public void initialize() {
		super.initialize();
		homeView = new HomePageView(this);
	}
}
